INCLUDES = -I./sdk -I"/usr/lib/jvm/java-11-openjdk-amd64/include" -I"/usr/lib/jvm/java-11-openjdk-amd64/include/linux"
#CPP_FLAGS =  -O2 -pipe -D__RJ_LINUX32__ -fPIC
CPP_FLAGS =  -O2 -pipe -D__RJ_LINUX64__ -fPIC -shared
DIRS = ./src
STATIC = yes
ifeq ($(STATIC), yes)
	LFLAGS = -L. ./lib/$(LIBS)/sdk.a
else
	LFLAGS = -L. ./lib/sdk.so #../lib/$(LIBS)/libmosquittopp.so
endif

SOURCES =  $(foreach cpps, $(DIRS), $(wildcard $(cpps)/*.cpp)) #.cpp
OBJS = $(SOURCES:%.cpp=%.o) #.cpp

ifeq ($(version), debug)
	BUILD_VER = -g
else
	BUILD_VER = -DNDEBUG
endif

#TARGET = ./sdks.a
#TARGET = sunell_cli
TARGET = ./libjingyang.so
.PHONY: $(TARGET) clean

%.o:%.cpp #.cpp
	$(CXX) $(INCLUDES) $(CPP_FLAGS) $(BUILD_VER) -c -o $@ $<

$(TARGET):$(OBJS)
	$(CXX) $(CPP_FLAGS) $(INCLUDES) -o $@ $+ $(LFLAGS) -lpthread -ldl -lrt;

clean:
	rm -rf $(OBJS)
	rm -rf $(TARGET)
